<link rel="stylesheet" href="/opebs/css/bootstrap.min.css">
<link rel="stylesheet" href="/opebs/css/bootstrap-select.css">
<script src="/opebs/js/jquery.min.js"></script>
<script src="/opebs/js/bootstrap.min.js"></script>
<script src="/opebs/js/bootstrap-select.js"></script>
<script src="/lib/jquery.form.js"></script>
<script type="text/javascript" src="/lib/layer/2.4/layer.js"></script>
<#include "/common/h-ui-base-css.html">
<#include "/common/validation-js.html">
<link href="/new-city-picker/css/city-picker.css" rel="stylesheet">
<link href="/new-city-picker/css/main.css" rel="stylesheet">
<script src="/new-city-picker/js/city-picker.data.js"></script>
<script src="/new-city-picker/js/city-picker.js"></script>
<script src="/new-city-picker/js/main.js"></script>
<!-- 文件上传 -->

<link href="/bootstrap-fileinput-master/css/fileinput.css" media="all" rel="stylesheet" type="text/css"/>
<script src="/bootstrap-fileinput-master/js/fileinput.js" type="text/javascript"></script>
<script src="/bootstrap-fileinput-master/js/locales/zh.js" type="text/javascript"></script>


<body>
    <div class="page-container">
        <form action="" method="post" class="form form-horizontal" id="form-project-add">
            <table class="table table-border table-bordered table-bg">
            <tbody>
                <tr>
                    <td hidden><input type="text" class="input-text" value="${uuid}" id="uuid" name="uuid" ></td>
                </tr>
                <tr>
                    <td>项目编号：<input type="text" class="input-text" value=""  placeholder="" id="proId" name="proId" ></td>
                    <td><span class="c-red">*</span>项目名称：<input type="text" class="input-text" value="" placeholder="" id="proName" name="proName"></td>
                    <td>
                        <span class="c-red">*</span>项目类别：<select id="proCategory" name="proCategory" class="selectpicker form-control"  data-live-search="true"  >
                        <option>请选择</option>
                        <#if category??>
                            <#list category as m>
                                <option data-tokens="${m.constantValuePY}" value="${m.constantValue}">${m.constantValueDesc}</option>
                            </#list>
                        </#if>
                    </select>
                    </td>
                    <td hidden>
                        <span class="c-red">*</span>项目状态：<span class="select-box">
                        <select name="proState" class="select" id="proState" readonly="true">
                            <option value="0" selected>入库</option>
                        </select>
                        </span>
                    </td>
                </tr>
            <tr>
                <td><span class="c-red">*</span>公司名称：<input type="text" class="input-text" value="" placeholder="" id="proCompany" name="proCompany"></td>
                <td><span class="c-red">*</span>地点：<input type="text" class="input-text" value="" placeholder="" id="proCompanyLocation" name="proCompanyLocation"></td>
                <td><span class="c-red">*</span>企业情况：<input type="text" class="input-text" value="" placeholder="" id="proCompanyCondition" name="proCompanyCondition"></td>
            </tr>
            <tr>
                <td>项目进度：<input type="text" class="input-text" value="" placeholder="" id="proLabel" name="proLabel"></td>
                <td><span class="c-red">*</span>企业需求：<input type="text" class="input-text" value="" placeholder="" id="proCompanyRequire" name="proCompanyRequire"></td>
                <td><span class="c-red">*</span>公司性质：<input type="text" class="input-text" value="" placeholder="" id="proCompanyNature" name="proCompanyNature"></td>
                <#--<td>-->
                    <#--<span class="c-red">*</span>公司性质：<select id="proCompanyNature" name="proCompanyNature" class="selectpicker form-control"  data-live-search="true" style="width: 100%;height: 100%">-->
                    <#--<option >请选择</option>-->
                    <#--<#if company??>-->
                        <#--<#list company as m>-->
                            <#--<option data-tokens="${m.constantValuePY}" value="${m.constantValueDesc}">${m.constantValueDesc}</option>-->
                        <#--</#list>-->
                    <#--</#if>-->
                <#--</select>-->
                </td>
            </tr>

                <#--<tr>-->
                    <#--<td>项目所在地：<input type="text" class="input-text" value="" placeholder="" id="city" name="city"></td>-->
                    <#--<td></td>-->
                    <#--<td>-->

                    <#--</td>-->
                <#--</tr>-->

            <#--<tr>-->
                <#--<td colspan="3">-->
                    <#--<div style="position: relative;">-->
                        <#--项目所在地：<input class="form-control" readonly type="text" id="city" name="city" data-toggle="city-picker" data-level="city" placeholder="请选择省/市">-->
                    <#--</div>-->
                <#--</td>-->
            <#--</tr>-->
             <tr>
                 <td colspan="3">
                     <span class="c-red">*</span>公司主营业务：<textarea  class="textarea" value="" placeholder="" id="proCompanyMain" name="proCompanyMain"></textarea>
                 </td>
             </tr>
            <tr class="text-c">
                <td colspan="3" >
                    <button  class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存</button>
                </td>
            </tr>
            </tbody>
        </table>
        </form>
    </div>
</body>

<script>
    var upladflagB1 = 'error';
    var upladflagB2 = 'error';
    var upladflagB3 = 'error';
    $(document).on('ready', function() {
        $("#inputB1").fileinput({
            language: 'zh',
            showBrowse: true,
            uploadUrl : "/upload-json/ruku/"+id,//图片上传的url，我这里对应的是后台struts配置好的的action方法
            enctype: 'multipart/form-data',
            showCaption: true,
            showPreview: false,
            previewZoomButtonClasses:'',
            preferIconicZoomPreview:false,
            theme: "explorer",
            dropZoneEnabled: false

        }).on('filepreupload', function(event, data, previewId, index){//上传中
        }).on("fileuploaded", function (event, data, previewId, index) {    //一个文件上传成功
            layer.msg("上传成功，可以再次添加上传新文件");
            upladflagB1 = 'ok'
        }).on('fileerror', function(event, data, msg) {  //一个文件上传失败
            console.log('文件上传失败！' + msg);
        })
        $("#inputB2").fileinput({
            language: 'zh',
            showBrowse: true,
            uploadUrl : "/upload-json/ruku/"+id,//图片上传的url，我这里对应的是后台struts配置好的的action方法
            enctype: 'multipart/form-data',
            showCaption: true,
            showPreview: false,
            previewZoomButtonClasses:'',
            preferIconicZoomPreview:false,
            theme: "explorer",
            dropZoneEnabled: false
        }).on('filepreupload', function(event, data, previewId, index){//上传中
        }).on("fileuploaded", function (event, data, previewId, index) {    //一个文件上传成功
            layer.msg("上传成功，可以再次添加上传新文件");
            upladflagB2 = 'ok';
        }).on('fileerror', function(event, data, msg) {  //一个文件上传失败
            console.log('文件上传失败！' + msg);
        });
        $("#inputB3").fileinput({
            language: 'zh',
            showBrowse: true,
            uploadUrl : "/upload-json/ruku/"+id,//图片上传的url，我这里对应的是后台struts配置好的的action方法
            enctype: 'multipart/form-data',
            showCaption: true,
            showPreview: false,
            theme: "explorer",
            dropZoneEnabled: false
        }).on('filepreupload', function(event, data, previewId, index){//上传中
        }).on("fileuploaded", function (event, data, previewId, index) {    //一个文件上传成功
            layer.msg("上传成功，可以再次添加上传新文件");
            upladflagB3 = 'ok';
        }).on('fileerror', function(event, data, msg) {  //一个文件上传失败
            console.log('文件上传失败！' + msg);
        });

    });
</script>

<script type="text/javascript">
    $("#form-project-add").validate({
        rules:{
            proName:{
                required:true,
                isCheck:true
            },
            proCategory:{
                required:true,
                isSelected:true
            },
            proCompanyCondition:{
                required:true
            },
            proCompany:{
                required:true
            },
            proCompanyLocation:{
                required:true
            },
            proCompanyMain:{
                required:true
            },
            proCompanyNature:{
                required:true,
                isSelected:true
            },
            proCompanyCondition:{
                required:true
            },
            proCompanyRequire:{
                required:true
            }
        },
        onkeyup:false,
        focusCleanup:true,
        success:"valid",
        submitHandler:function(form){
            // if(upladflagB1==='error'||upladflagB2==='error'||upladflagB3==='error'){
            //     layer.msg("请长传以下所有类别的文件");
            //     return;
            // }
            $(form).ajaxSubmit({
                type: 'post',
                url: "/project-ins-upd-del/-1" ,
                data :$("form-project-add").serialize(),
                async:false,
                success: function(data){

                    layer.msg('添加成功!',{icon:1,time:1000});
                },
                error: function(XmlHttpRequest, textStatus, errorThrown){
                    layer.msg('error!',{icon:1,time:1000});
                }
            });
            var index = parent.layer.getFrameIndex(window.name);
            var handler = '/project-list/0/1/20';
            parent.$('#project_table').datagrid('options').url = handler;
            parent.$('#project_table').datagrid('reload');
            parent.layer.close(index);
        }
    });
    jQuery.validator.addMethod("isCheck", function(value, element) {
        var flag = '';
        $.ajax({
            type :'post',
            url : '/project-name-check/'+value+'/',
            async :false,
            success :function(data){
                flag = data;
            }
        });
        return this.optional(element) || ( flag!="exist" );
    }, "登录名称重复，请重新输入");
    jQuery.validator.addMethod("isSelected", function(value, element) {
        var flag = this.optional(element) || ( value!='请选择' );
        if(!flag){
            layer.msg("请选择相应的信息")
        }
        return flag;
    },'请选择');
    jQuery.validator.addMethod("isUpload1", function(value, element) {
        var flag = (upladflagB1=='ok');
        if(!flag){
            layer.msg("请上传文件1")
        }
        return flag;
    },'请选择');
    jQuery.validator.addMethod("isUpload2", function(value, element) {
        var flag = (upladflagB2=='ok');
        console.log(flag)
        if(!flag){
            layer.msg("请上传文件2")
        }
        return flag;
    },'请选择');
    jQuery.validator.addMethod("isUpload3", function(value, element) {
        var flag = (upladflagB3=='ok');
        if(!flag){
            layer.msg("请上传文件3")
        }
        return flag;
    },'请选择');
</script>

